from tools_algorithm import *


class Solution:
    def numberOfPairs(self, points: List[List[int]]) -> int:
        points.sort(key=lambda a: (a[0], -a[1]))
        n = len(points)
        ans = 0
        for i in range(n - 1):
            ax, ay = points[i][0], points[i][1]
            for j in range(i + 1, n):
                bx, by = points[j][0], points[j][1]
                if ay < by:
                    continue
                ans += 1
                for k in range(i + 1, j):
                    kx, ky = points[k][0], points[k][1]
                    if ax <= kx and kx <= bx and by <= ky and ky <= ay:
                        ans -= 1
                        break
        return ans


s = Solution()
print(s.numberOfPairs([[0, 1], [1, 3], [6, 1]]))
# print(s.numberOfPairs([[6, 2], [4, 4], [2, 6]]))
